import 'package:flutter/material.dart';
import 'package:fluttertoast/fluttertoast.dart';

// 通用响应
class CommonResponse {
  int? status;
  String? msg;
  int? what;
  bool? trueOrFalse;

  CommonResponse.fromMap(Map<String, dynamic>? json) {
    status = json?['status'];
    msg = json?['msg'];
    what = json?['what'];
    trueOrFalse = json?['trueOrFalse'];
  }

  Map<String, dynamic> toMap() {
    final json = <String, dynamic>{};
    json['status'] = status;
    json['msg'] = msg;
    json['what'] = what;
    json['trueOrFalse'] = trueOrFalse;
    return json;
  }
}

class SchoolAnnouncementDetailResponse {
  int? status;
  String? msg;
  SchoolAnnouncementDetailEntity? detailEntity;

  SchoolAnnouncementDetailResponse.fromMap(Map<String, dynamic>? json) {
    status = json?['status'];
    msg = json?['msg'];
    detailEntity =
        SchoolAnnouncementDetailEntity.fromMap(json?['detail_entity']);
  }
}

class SchoolAnnouncementDetailEntity {
  String? title;
  String? time;
  String? author;
  List<String?>? contentList;
  List<String?>? imgList;

  SchoolAnnouncementDetailEntity.fromMap(Map<String, dynamic>? json) {
    title = json?['title'];
    time = json?['time'];
    author = json?['author'];
    contentList = [];
    imgList = [];
    (json?['content_list'] as List?)?.forEach((element) {
      contentList?.add(element);
    });
    (json?['img_list'] as List?)?.forEach((element) {
      imgList?.add(element);
    });
  }
}

// 学校公告反应
class SchoolAnnouncementResponse {
  int? status;
  String? msg;
  List<SchoolAnnouncementEntity?>? announcementList;

  SchoolAnnouncementResponse.fromMap(Map<String, dynamic>? json) {
    status = json?['status'];
    msg = json?['msg'];
    announcementList = [];
    (json?['announcement_list'] as List?)?.forEach((element) {
      announcementList?.add(SchoolAnnouncementEntity.fromMap(element));
    });
  }
}

// 学校公告实体
class SchoolAnnouncementEntity {
  String? mainTitle;
  List<ContentEntity?>? contentList;

  SchoolAnnouncementEntity.fromMap(Map<String, dynamic>? json) {
    mainTitle = json?['main_title'];
    contentList = [];
    (json?['content_list'] as List?)?.forEach((element) {
      contentList?.add(ContentEntity.fromMap(element));
    });
  }
}

class ContentEntity {
  String? time;
  String? content;
  String? url;

  ContentEntity.fromMap(Map<String, dynamic>? json) {
    time = json?['time'];
    content = json?['content'];
    url = json?['url'];
  }
}

// 图片反馈实体
class PhotoListResponse {
  int? status;
  String? msg;
  List<PhotoEntity?>? list;

  PhotoListResponse.fromMap(Map<String, dynamic>? json) {
    status = json?['status'];
    msg = json?['msg'];
    list = [];
    (json?['photo_list'] as List?)?.forEach((element) {
      list?.add(PhotoEntity.fromMap(element));
    });
  }
}

// 图片实体
class PhotoEntity {
  String? iconId;
  String? iconSrc;
  Color photoColor = Colors.white;

  PhotoEntity.fromMap(Map<String, dynamic>? json) {
    iconId = json?['icon_id'];
    iconSrc = json?['icon_src'];
  }
}

// 单个备忘录反馈
class SingleMemorandumResponse {
  int? status;
  String? msg;
  MemorandumEntity? memorandumEntity;

  SingleMemorandumResponse.fromMap(Map<String, dynamic>? json) {
    status = json?['status'];
    msg = json?['msg'];
    memorandumEntity = MemorandumEntity.fromMap(json?['note']);
  }
}

// 用户备忘录列表反馈
class UserMemorandumListResponse {
  int? status;
  String? msg;
  int? pageSize;
  int? currentPage;
  bool? haveMore;
  List<MemorandumEntity?>? memorandumList;

  UserMemorandumListResponse.fromMap(Map<String, dynamic>? json) {
    status = json?['status'];
    msg = json?['msg'];
    pageSize = json?['page_size'];
    currentPage = json?['current_page'];
    haveMore = json?['have_more'];
    memorandumList = [];
    (json?['note_list'] as List?)?.forEach((element) {
      memorandumList?.add(MemorandumEntity.fromMap(element));
    });
  }
}

// 备忘录实体
class MemorandumEntity {
  String? noteId; // 备忘录id
  String? title; // 备忘录标题
  String? msg; // 备忘录内容
  String? recordStartTime; // 备忘录记录时间
  String? lastEditTime; // 备忘录上次修改时间
  String? account; // 账号

  Color defaultColor = const Color(0x66B8DCFF); // 默认颜色
  bool isSelect = false;

  MemorandumEntity.fromMap(Map<String, dynamic>? json) {
    noteId = json?['note_id'];
    title = json?['title'];
    msg = json?['msg'];
    account = json?['account'];
    recordStartTime = json?['record_start_time'];
    lastEditTime = json?['last_edit_time'];
  }
}

// 天气回应反馈
class WeatherCommonResponse {
  int? status;
  String? msg;
  WeatherMessage? weatherMessage;

  WeatherCommonResponse.fromMap(Map<String, dynamic>? resultMap) {
    status = resultMap?['status'];
    msg = resultMap?['msg'];
    weatherMessage = WeatherMessage.fromMap(resultMap?['weather']);
  }
}

// 天气信息
class WeatherMessage {
  int? temperature;
  String? location;
  String? date;
  String? weatherType;

  WeatherMessage.fromMap(Map<String, dynamic>? resultMap) {
    temperature = resultMap?['temperature'];
    location = resultMap?['location'];
    date = resultMap?['date'];
    weatherType = resultMap?['weather_type'];
  }
}

// 朋友圈信息回应
class FriendCircleMessageResponse {
  int? status; // 朋友圈状态
  String? msg; // 异常信息
  int? currentPage; // 当前页面
  bool? haveMore; // 是否有更多信息
  List<FriendCircleMessage>? messageList; // 朋友圈列表

  FriendCircleMessageResponse.fromMap(Map<String, dynamic>? resultMap) {
    status = resultMap?['status'];
    msg = resultMap?['msg'];
    currentPage = resultMap?['currentPage'];
    haveMore = resultMap?['have_more'];
    messageList = [];
    (resultMap?['friend_circle_message_list'] as List?)?.forEach((element) {
      messageList?.add(FriendCircleMessage.fromMap(element));
    });
  }
}

class FriendCircleMessage {
  String? conversationId;
  String? account; // 消息账号
  PhotoEntity? icon; // 头像
  String? accountNickname; // 信息发送者名称
  String? location; // 发送地点
  String? message; // 发送的消息内容
  String? sendTime; // 朋友圈发送时间
  bool? isLove; // 是否被选中
  int? loveCount; // 点赞
  Color defaultColor = const Color(0x66D0E7FF);
  List<FriendCircleCommit?>? commitList; // 评论列表

  FriendCircleMessage.fromMap(Map<String, dynamic>? resultMap) {
    conversationId = resultMap?['conversation_id'];
    message = resultMap?['message'];
    location = resultMap?['location'];
    account = resultMap?['sender_account'];
    accountNickname = resultMap?['sender_name'];
    icon = PhotoEntity.fromMap(resultMap?['sender_icon']);
    loveCount = resultMap?['agree_count'];
    isLove = resultMap?['is_love'];
    sendTime = resultMap?['time'];
    commitList = [];
    (resultMap?['commit'] as List?)?.forEach((element) {
      commitList?.add(FriendCircleCommit.fromMap(element));
    });
  }
}

// 评论返回
class FriendCircleCommitResponse {
  int? status; // 状态码
  String? msg; // 状态信息
  List<FriendCircleCommit?>? commitList; // 评论列表

  FriendCircleCommitResponse.fromMap(Map<String, dynamic>? resultMap) {
    status = resultMap?['status'];
    msg = resultMap?['msg'];
    commitList = [];
    (resultMap?['commit_item'] as List?)?.forEach((element) {
      commitList?.add(FriendCircleCommit.fromMap(element));
    });
  }
}

// 评论信息实体
class FriendCircleCommit {
  String? conversationId; // 对话id
  String? commitId; // 评论id
  String? commitMsg; // 评论信息
  String? commitTime; // 评论时间
  PersonalInfoResponse? commitUser; // 评论人
  PersonalInfoResponse? commitToWho; // 被评论人

  FriendCircleCommit.fromMap(Map<String, dynamic>? resultMap) {
    conversationId = resultMap?['conversation_id'];
    commitId = resultMap?['commit_id'];
    commitMsg = resultMap?['commit_message'];
    commitTime = resultMap?['commit_time'];
    commitUser = PersonalInfoResponse.fromMap(resultMap?['commit_user']);
    commitToWho = PersonalInfoResponse.fromMap(resultMap?['commit_to_who']);
  }
}

class PersonalInfoResponse {
  int? status; // 状态码
  PhotoEntity? icon; // 头像
  String? account; // 账号
  String? power; // 权力
  String? nickname; // 昵称
  int? friendCircleCount; // 朋友圈个数
  int? sex; // 性别
  SchoolEntity? school; // 学校
  String? phone; // 电话
  String? area; // 地区
  String? studentId; // 学生id
  String? teacherId; // 教师id
  String? administratorId; // 管理员id
  String? teachClass; // 所教课程
  String? personalProfile; // 个人简介

  PersonalInfoResponse.fromMap(Map<String, dynamic>? resultMap) {
    status = resultMap?['status'];
    icon = PhotoEntity.fromMap(resultMap?['icon']);
    account = resultMap?['account'];
    power = resultMap?['power'];
    nickname = resultMap?['nickname'];
    friendCircleCount = resultMap?['friend_circle_count'];
    sex = resultMap?['sex'];
    school = SchoolEntity.fromMap(resultMap?['school']);
    phone = resultMap?['phone'];
    area = resultMap?['area'];
    studentId = resultMap?['student_id'];
    teacherId = resultMap?['teacher_id'];
    administratorId = resultMap?['administrator_id'];
    teachClass = resultMap?['teach_class'];
    personalProfile = resultMap?['personal_profile'];
  }
}

class AllSchoolResponse {
  int? status;
  String? msg;
  List<SchoolEntity?>? schoolList;

  AllSchoolResponse.fromMap(Map<String, dynamic>? resultMap) {
    status = resultMap?['status'];
    msg = resultMap?['msg'];
    schoolList = [];
    (resultMap?['school_list'] as List?)?.forEach((element) {
      schoolList?.add(SchoolEntity.fromMap(element));
    });
  }
}

class UserSchoolResponse {
  int? status;
  String? msg;
  SchoolEntity? school;

  UserSchoolResponse.fromMap(Map<String, dynamic>? resultMap) {
    status = resultMap?['status'];
    msg = resultMap?['msg'];
    school = SchoolEntity.fromMap(resultMap?['school']);
  }
}

class SchoolEntity {
  int? schoolId;
  String? schoolName;
  String? schoolWebUrl;
  int? parseType;

  SchoolEntity.fromMap(Map<String, dynamic>? resultMap) {
    schoolId = resultMap?["school_id"];
    schoolName = resultMap?["school_name"];
    schoolWebUrl = resultMap?["school_web_url"];
    parseType = resultMap?["parse_type"];
  }
}

enum CommonLoadingState { loading, successTypeOne, successTypeTwo, failure }

// enum CommonWeatherState {
//   sunny, // 晴天
//   cloudy, // 阴天
//   lightRain, // 小雨
//   torrentialRain, // 暴雨
//   snow, // 雪天
//   blizzard, // 暴雪
//   mudslide, // 泥石流
//   fog // 雾天
// }
